#ifndef cp1252_h
#define cp1252_h

// this header needs
#include "wchar.h"
#include "ascii.h"

// cp1252 is a windows encoding that maps almost all possible
// 8 binary digits combinations to characters. It includes ascii
// so it is simple and useful.
// https://en.wikipedia.org/wiki/Windows-1252

// in TLOZ: TWW
// - the 0x5C character shows up like a yen sign
// - the 0xB8 character (currency symbol) does not show up

#define OWL_MIN_CP1252 0x00
#define OWL_MAX_CP1252 0xFF
#define OWL_INV_CP1252 0x81
// the other invalid integer positions are 0x8D, 0x8F, 0x90 and 0x9D
#define OWL_INV_CP1252_STR     "[INV_CP1252_INT]"
#define OWL_INV_ENC_CP1252_STR "[INV_ENC_CP1252]"

// character constants (wchar.h)
owl_wchar OWL_CP1252_NUM[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
                              'A', 'B', 'C', 'D', 'E', 'F',
                              'a', 'b', 'c', 'd', 'e', 'f',
                              '+', '-', '.', 'X', 'x'};
owl_wchar OWL_CP1252_WSP[] = {'\t', '\n', '\v', '\f', '\r', ' '};
owl_wchar OWL_CP1252_PATH[] = {'/', '\\', '.'};
owl_wchar OWL_CP1252_LETR[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 
                               'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
                               'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
                               'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
#define OWL_CP1252_NULL 0x00

// basic functions
owl_byte owl_check_wchar_cp1252(owl_wchar ch);
owl_byte owl_check_wchar_enc_cp1252(owl_byte * src, owl_umax size);
owl_wchar owl_get_wchar_cp1252(owl_byte * src, owl_umax size);
owl_byte * owl_write_wchar_enc_cp1252(owl_wchar ch, owl_byte * dest, owl_umax size);
owl_byte owl_print_wchar_cp1252(owl_wchar ch);
owl_byte owl_print_wchar_enc_cp1252(owl_byte * src, owl_umax size);

#include "cp1252.c"

// conversion to unicode
owl_wchar owl_wchar_cp1252_as_unicode(owl_wchar cp1252);
owl_wchar owl_wchar_unicode_as_cp1252(owl_wchar unicode);

#include "cp1252_unicode.c"

#endif // cp1252_h
